package yadong.example.code;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;

public class QRCodeGenerator {
  
 
    /** 
     * @param args 
     */  
    public static void main(String[] args) {  
    	String url ="http://192.168.1.3/gog/movies/mud,1247028.html";
    	 url ="hello word!";
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
    	Integer width = 200;
    	Integer height = 200;
    	String imageFormat = "jpg"; // could be "gif", "tiff", "jpeg"
    	String filePath="/Volumes/HD2T/qrcode-"+""+sdf.format(new Date())+".png";
    	try {
    		BitMatrix bitMatrix = new QRCodeWriter().encode(url, BarcodeFormat.QR_CODE, width, height);
    		MatrixToImageWriter.writeToFile(bitMatrix, imageFormat, new File(filePath));
			
		} catch (Exception e) {
			e.printStackTrace();
		}
    }  
    
    

}
